
try:
    f = open('4.txt', 'r')
except FileNotFoundError as e:
    f = open('4.txt', 'w+')
else:
    print('没有异常，真开心')
finally:
    f.close()


name = 'wsl'
try:
    print(name)
except Exception as e:
    print(e)

try:
    print(1/0)
except (NameError, ZeroDivisionError):
    print('ZeroDivision错误...')
else:
    print('我是else，是没有异常的时候执行的代码')


# 异常传递性 在main中捕获异常
